pub mod log_item;
pub mod version_info;
pub mod app_files;

use serde::{Serialize, Deserialize};
use log_item::LogItem;

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all="camelCase")]
pub struct AppLog {
  pub server_name: String,
  pub log_list: Vec<LogItem>,
}

impl AppLog {
  pub fn add_log(&mut self, log_item: LogItem) {
    self.log_list.insert(0, log_item);
  }

  pub fn get_last_log(&self) -> Option<&LogItem> {
    if self.log_list.len() == 0 {
      return None;
    }
    return Some(&self.log_list[0]);
  }

  pub fn get_mut_list(&mut self) -> &mut Vec<LogItem> {
    return &mut self.log_list;
  }

  pub fn get_list(&self) -> &Vec<LogItem> {
    return &self.log_list;
  }

  pub fn new(server_name: String) -> Self {
    return AppLog { server_name, log_list: Vec::new() };
  }
}
